<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app"></div>
</body>
<script src="https://unpkg.com/vue@next"></script>
<script>
    const {ref,watch,reactive }=Vue
    const app=Vue.createApp({
        template:`
        First Name:<input v-model="firstName" /><br>
        Last Name:<input v-model="lastName" /><br>
        Full Name:<input v-model="fullName" /><br>
        岗位:<input v-model="job.type"/><br>
        薪资:<input v-model="job.salary"/><br>`,
    setup(props) {
        let firstName=ref('田');
        let lastName=ref('嘉');
        let fullName=ref('');
        let job=reactive({
                type:'java开发工程师',salary:'25k'
            })
        //侦听单个数据源
       /*  watch(firstName,function(newVal,oldVal){
            console.log("当前值：",newVal,'之前值：',oldVal)
            fullName.value=firstName.value+""+lastName.value
        })
        watch(lastName,function(newVal,oldVal){
            console.log("当前值：",newVal,'之前值：',oldVal)
            fullName.value=firstName.value+""+lastName.value
        }) */
        //侦听多个数据源
      /*   watch([firstName,lastName],function(newVal,oldVal){
            console.log('当前值:',newVal,'之前值:',oldVal)
            fullName.value=firstName.value+""+lastName.value
        }) */
        watch([()=>job.type,()=>job.salary],function(newVal,oldVal){
            console.log('当前值:',newVal,'之前值:',oldVal),{immediate:true,deep:true}
        })
        return{
            firstName,lastName,fullName,job
        }
    }
    })
    app.mount("#app")
</script>
</html>